package letsjava.utils;

import java.util.*;

public class NSTemplateList<T> {
	private ArrayList<T> list = new ArrayList<T>();
	
	public void add(T a){
		list.add(a);
	}
	public T popFirst(){
		if(list.isEmpty()){
			return null;
		}
		T a = list.get(0);
		list.remove(0);
		return a; 
	}
	public T popLast(){
		if(list.isEmpty()){
			return null;
		}
		T a = list.get(list.size()-1);
		list.remove(list.size()-1);
		return a; 
	}
	public String toString(){
		StringBuffer a = new StringBuffer();
		Iterator b = list.iterator();
		while(b.hasNext()){
			a.append(b.next().toString()+",");
		}
		return a.toString();
	}
	
}
